<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>修改员工列表</h1>
<form action="">
  <input type="text" name="id" placeholder="id" :value="emp.id" readonly>
  <input type="text" name="name" placeholder="姓名" :value="emp.name">
  <input type="text" name="sal" placeholder="工资" :value="emp.sal">
  <input type="text" name="job" placeholder="工作" :value="emp.job">
  <input type="button" value="修改" @click="update()">
</form>
<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<script>
  let v = new Vue({
    el:"form",
    data:{
      emp:{}
    },
    created:function (){
      let id = location.search.split("=")[1];
      axios.get("/selectById?id="+id).then(function (response){
        v.emp = response.data;
      })
    },
    methods:{
      update(){
        let data = new FormData(document.querySelector("form"));
        axios.post("/update",data).then(function (response){
          alert("修改完成!");
          location.href = "/list.html";
        })
      }
    }
  })
</script>
</body>
</html>